package com.symone.webcms.service.impl;

import com.symone.webcms.model.Notification;
import com.symone.webcms.mapper.NotificationMapper;
import com.symone.webcms.service.NotificationService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.stereotype.Service;
import java.util.List;
/**
 *　　
 *   @description : Notification 服务实现类
 *   ---------------------------------
 * 	 @author Archer Chu
 *   @since 2019-03-19
 */
@Service
public class NotificationServiceImpl extends ServiceImpl<NotificationMapper, Notification> implements NotificationService {

    @Override
    public Page<Notification> findPage(Page<Notification> page, Wrapper<Notification> notification) {
        List<Notification> result = baseMapper.selectPage(page,notification);
        page.setRecords(result);
        return page;
    }

    @Override
    public List<Notification> findAll() {
        Wrapper<Notification> ew = new EntityWrapper<Notification>();
        ew.where("deleted=0");
        return baseMapper.selectList(ew);
    }

    @Override
    public int delete(long id) {
        return baseMapper.deleteById(id);
    }

    @Override
    public int clearAllByUid(Long userId) {
        return baseMapper.deleteByUid(userId);
    }

    @Override
    public void setAllRead(Long userId) {
        baseMapper.updateReadByUid(userId);
    }

}
